package com.clqteam.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.clqteam.model.Employee;
import com.clqteam.service.DailyService;
import com.clqteam.service.UpdateVIPLXGService;
import com.clqteam.serviceimpl.DailyServiceImpl;
import com.clqteam.serviceimpl.UpdateVIPLXGServiceImpl;
/**
 * VIP修改功能的controller
 * @author Administrator
 *
 */
public class UpdateVIPLXGController extends HttpServlet{
	UpdateVIPLXGService uvs=new UpdateVIPLXGServiceImpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding("utf8");
		resp.setCharacterEncoding("utf8");
		//引用日志
	    DailyService ds=new DailyServiceImpl();
		HttpSession session=req.getSession();
		Employee e=(Employee) session.getAttribute("employee");
		int eId=e.geteId();
		String eName=e.geteName();
		String function="修改会员信息";
		
		String vid=req.getParameter("vId");
		int vId=Integer.parseInt(vid);
		
		String vPo=req.getParameter("vPoint");
		int vPoint=Integer.parseInt(vPo);
		
		String pit=req.getParameter("pitRate");
		double pitRate=Double.parseDouble(pit);
		
		String vdis=req.getParameter("vDiscount");
		double vDiscount=Double.parseDouble(vdis);
		
		String vTime=req.getParameter("vTime");
		boolean b=uvs.updateVIPByVId(vId, vPoint, pitRate, vDiscount, vTime);
		
		PrintWriter pw=resp.getWriter();
		if(b=true){
			ds.functionDaily(function, eId, eName);
			pw.write("1");
		}else{
			pw.write("0");
		}
		pw.flush();
		pw.close();
	}
}
